home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / checkbox / plugins / subunit_report.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2009-10-12  |  2.1 KB  |  49 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import logging
  5. from checkbox.test import FAIL, PASS, SKIP
  6. from checkbox.properties import Path
  7. from checkbox.plugin import Plugin
  8.  
  9. class SubunitReport(Plugin):
  10.     filename = Path(default = '%(checkbox_data)s/subunit.log')
  11.     result_status_table = {
  12.         FAIL: 'failure',
  13.         PASS: 'success',
  14.         SKIP: 'skip' }
  15.     
  16.     def register(self, manager):
  17.         super(SubunitReport, self).register(manager)
  18.         self._file = None
  19.         for rt, rh in [
  20.             ('gather', self.gather),
  21.             ('report-result', self.report_result)]:
  22.             self._manager.reactor.call_on(rt, rh)
  23.         
  24.  
  25.     
  26.     def gather(self):
  27.         logging.debug('Opening filename: %s', self.filename)
  28.         self._file = open(self.filename, 'w')
  29.  
  30.     
  31.     def report_result(self, result):
  32.         test = result.test
  33.         name = '%s %s' % (test.suite, test.name)
  34.         self._file.write('test: %s\n' % name)
  35.         tags = []
  36.         if tags:
  37.             self._file.write('tags: %s\n' % ' '.join(tags))
  38.         
  39.         status = self.result_status_table[result.status]
  40.         self._file.write('%s: %s' % (status, name))
  41.         if result.data:
  42.             data = result.data.replace('\n', '\n ').strip()
  43.             self._file.write(' [\n %s\n]\n' % data)
  44.         else:
  45.             self._file.write('\n')
  46.  
  47.  
  48. factory = SubunitReport
  49.